package com.ruoyi.web.controller.shortplay;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shortplay.domain.ShortPlayAll;
import com.ruoyi.shortplay.service.IShortPlayAllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 木枕溪现有微短剧Controller
 *
 * @author ruoyi
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/play/allTwo")
public class ShortPlayAllController extends BaseController {
    @Autowired
    private IShortPlayAllService shortPlayAllService;

    /**
     * 查询木枕溪现有微短剧列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShortPlayAll shortPlayAll) {
        startPage();
        List<ShortPlayAll> list = shortPlayAllService.selectShortPlayAllCopyRight(shortPlayAll);
        return getDataTable(list);
    }

    /**
     * 导出木枕溪现有微短剧列表
     */
    @PreAuthorize("@ss.hasPermi('play:all:export')")
    @Log(title = "木枕溪现有微短剧", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShortPlayAll shortPlayAll) {
        List<ShortPlayAll> list = shortPlayAllService.selectShortPlayAllList(shortPlayAll);
        ExcelUtil<ShortPlayAll> util = new ExcelUtil<ShortPlayAll>(ShortPlayAll.class);
        util.exportExcel(response, list, "木枕溪现有微短剧数据");
    }

    /**
     * 获取木枕溪现有微短剧详细信息
     */
    @PreAuthorize("@ss.hasPermi('play:all:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(shortPlayAllService.selectShortPlayAllById(id));
    }

    /**
     * 新增木枕溪现有微短剧
     */
    @PreAuthorize("@ss.hasPermi('play:all:add')")
    @Log(title = "木枕溪现有微短剧", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShortPlayAll shortPlayAll) {
        return toAjax(shortPlayAllService.insertShortPlayAll(shortPlayAll));
    }

    /**
     * 修改木枕溪现有微短剧
     */
    @PreAuthorize("@ss.hasPermi('play:all:edit')")
    @Log(title = "木枕溪现有微短剧", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShortPlayAll shortPlayAll) {
        return toAjax(shortPlayAllService.updateShortPlayAll(shortPlayAll));
    }

    /**
     * 删除木枕溪现有微短剧
     */
    @PreAuthorize("@ss.hasPermi('play:all:remove')")
    @Log(title = "木枕溪现有微短剧", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(shortPlayAllService.deleteShortPlayAllByIds(ids));
    }
}
